<template>
  <el-dialog title="委外订单信息" :close-on-click-modal="false" :visible.sync="visible" fullscreen append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-form :model="dataForm" ref="dataForm"  label-width="120px" disabled>
      <el-row :gutter="15">
          <el-col :span="8">
            <el-form-item label="订单单号" >
              <el-input v-model="dataForm.billId" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="订单类型" >
              {{getSaleType(dataForm.consignType)}}
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="制单人" >
              <el-input v-model="dataForm.createUserName" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="收货联系人" >
              <el-input v-model="dataForm.takeContactName"  readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货联系电话" >
              <el-input v-model="dataForm.takePhone" readonly></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="收货联系传真">
              <el-input v-model="dataForm.takeFax" readonly></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="收货地址" >
          <el-input  v-model="dataForm.takeAddress" type="textarea" readonly></el-input>
        </el-form-item>
        <el-form-item label="备注" >
          <el-input v-model="dataForm.memo" type="textarea" readonly></el-input>
        </el-form-item>

    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading">
      <el-table-column prop="billId" label="收货单号" width="140"></el-table-column>
      <el-table-column prop="goodsDisplayName" label="商品名称"></el-table-column>
      <el-table-column prop="goodsCode" label="商品代码" width="150"></el-table-column>
      <el-table-column prop="goodsQuantity" label="收货数量" width="80"></el-table-column>
      <el-table-column prop="batch" label="批次" width="100"></el-table-column>
      <el-table-column prop="invalidTime" label="失效日期" width="160"></el-table-column>
      <el-table-column prop="registerNum" label="注册证号" width="160"></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
  import {mapGetters} from 'vuex'
  import { remote } from '@/api/admin/dict'
  import { checkConsignDetailByBillId } from '@/api/eims/consign/consignOrder'


  export default {
    data() {
      return {
        activeName: '配镜单详情',
        visible: false,
        printUrl: '',
        dataForm: {},
        dataList: [],
        saleTypeData: [],
        dataListLoading: false
      }
    },
    computed: {
      ...mapGetters(['bizData'])
    },
    methods: {
      init(number){
        remote('sale_type').then(result => {
          this.saleTypeData = result.data.data
        })
        this.visible = true
        this.$nextTick(() => {
					this.dataListLoading = true
          checkConsignDetailByBillId(number).then(response => {
            if(response.data.code == '0'){
              this.dataForm = response.data.data
              let goodsData = response.data.data.detailList
              this.dataList = goodsData
            }else{
              this.$message.error(response.data.msg)
            }
            this.dataListLoading = false
          })
        })
      },
      getSaleType(value) {
          let obj = {};
          obj = this.saleTypeData.find((item)=>{
              return item.value == value;
          });
          if(obj && obj.label){
              return obj.label;
          }
      },
      //  打印配镜单
      saleGlassPrint(id) {
        let params = '/saleGlassPrint_ykyy.cpt&wFlag=1&saleId='
        this.printUrl = this.bizData.printUrl + params + id
      },
    }

  }
</script>
<style lang="scss" scoped>
.miui-table {
  width: 100%;
}
  .miui-table tr>th,.miui-table tr>td {
    border: solid 1px #fff;
    height: 33px;
		background-color: #b1e2ec3b;
    padding: 3px 5px;
    text-align: center;
  }
</style>
